package com.dituhui.gps.local;

import com.dituhui.tool.algorithm.UUIDGenerator;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 创建用户组织
 * 
 * @author liweigu
 *
 */
public class BuildUserGroup {

	public static void main(String[] args) {
		String uuid = "2c908ed75b479573015b4795733d0000";
		String groupName = "HappyHome";
		String userName = "李玮顾";
		String userPhone = "13540060733";
		String subUserName = "《怡》 ";
		String subUserPhone = "13558724966";
		// String uuid = "8a8a80595c80f776015c80f776730000";
		// String groupName = "冀北-橱柜的团队";
		// String userName = "冀北-橱柜";
		// String userPhone = "13393090730";
		// String uuid = "8a8a80595c8666f6015c8666f6470000";
		// String groupName = "L的团队";
		// String userName = "L";
		// String userPhone = "13412146966";
		// String uuid = "402880e75c87c54f015c87c54f8c0000";
		// String groupName = "怡的团队";
		// String userName = "《怡》 ";
		// String userPhone = "13558724966";
		// String uuid = "402880e85c94c844015c94c844ef0000";
		// String groupName = "沙的团队";
		// String userName = "沙";
		// String userPhone = "15640358501";
		// String json = build(uuid, groupName, userName, userPhone);
		// String uuid = "402880e95c9c3d9f015c9c3d9fab0000";
		// String groupName = "persuse的团队";
		// String userName = "persuse";
		// String userPhone = "18661757585";
		// String uuid = "8a8a81d85cd27348015cd273481a0000";
		// String groupName = "韩晴的团队";
		// String userName = "韩晴 i゛";
		// String userPhone = "18725302020";
		// String uuid = "402880ea5cddc694015cddc694a10000";
		// String groupName = "杭的团队";
		// String userName = "杭";
		// String userPhone = "13729610920";
		// String subUserName = "可人";
		// String subUserPhone = "13620569494";
		// String uuid = UUIDGenerator.generate();
		String json = build(uuid, groupName, userName, userPhone, subUserName, subUserPhone);
		System.out.println(json);
	}

	public static String build(String uuid, String groupName, String userName, String userPhone, String subUserName, String subUserPhone) {
		JSONObject jsonObject = new JSONObject();
		JSONObject group = new JSONObject();
		group.accumulate("uuid", uuid);
		group.accumulate("name", groupName);
		group.accumulate("visit", "open");
		jsonObject.accumulate("group", group);
		JSONArray userInfos = new JSONArray();
		JSONObject userInfo = new JSONObject();
		userInfo.accumulate("phone", userPhone);
		userInfo.accumulate("name", userName);
		userInfos.add(userInfo);
		if (subUserName != null) {
			userInfo = new JSONObject();
			userInfo.accumulate("phone", subUserPhone);
			userInfo.accumulate("name", subUserName);
			userInfos.add(userInfo);
		}
		// userInfo = new JSONObject();
		// userInfo.accumulate("phone", "13558724966");
		// userInfo.accumulate("name", "《怡》 ");
		// userInfos.add(userInfo);
		jsonObject.accumulate("userInfos", userInfos);
		JSONArray admins = new JSONArray();
		JSONObject admin = new JSONObject();
		admin.accumulate("phone", userPhone);
		admin.accumulate("name", userName);
		admins.add(admin);
		// admin = new JSONObject();
		// admin.accumulate("phone", "13558724966");
		// admin.accumulate("name", "《怡》 ");
		// admins.add(admin);
		jsonObject.accumulate("admins", admins);
		JSONObject manager = new JSONObject();
		manager.accumulate("phone", userPhone);
		manager.accumulate("name", userName);
		jsonObject.accumulate("manager", manager);
		return jsonObject.toString();
	}

}
